<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>清除浮动</title>

    <style>
      ul>li{
        list-style: none;
      }


      /* 伪类方式 */
      .list::after{
        content: '';
        display: block;
        clear: both;
      }




      /* 额外标签方式 */
      /* .clearFloat{
        clear: both;
      } */



      /* BFC方式 */
      .list{
        overflow: hidden;
      }
      .item {
        height: 100px;
        width: 100px;
        font-size: 40px;
        text-align: center;
        line-height: 100px;
        float: left;
        
      }
      .item:nth-child(2n) {
        background: pink;
      }
      .item.item:nth-child(2n-1) {
        background: lightgreen;
      }
    </style>
  </head>
  <body>
    <ul class="list">
      <li class="item">1</li>
      <li class="item">2</li>
      <li class="item">3</li>
      <li class="item">4</li>
      <li class="item">5</li>
      <!-- <p class="clearFloat"></p> -->
    </ul>
    <div class="wrap">Hello</div>
  </body>
</html>
